package com.chenfan.mcn.dao;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.chenfan.common.extension.mybatisplus.enhanced.EnhancedBaseMapper;
import com.chenfan.mcn.model.DepartmentTarget;
import com.chenfan.mcn.model.McnPage;
import com.chenfan.mcn.model.dto.DepartmentTargetSearchDTO;
import com.chenfan.mcn.model.vo.DepartmentTargetListVO;
import com.chenfan.mcn.model.vo.DepartmentTargetPageVO;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author lizhejin
 * @since 2021-04-20
 */
public interface DepartmentTargetMapper extends EnhancedBaseMapper<DepartmentTarget> {

    /**
     * 部门目标列表
     *
     * @param dto
     * @return List<DepartmentTargetListVO> {@link DepartmentTargetListVO}
     */
    List<DepartmentTargetListVO> targetList(@Param("dto") DepartmentTargetSearchDTO dto);

    /**
     * 季度销售额更新落库
     *
     * @param departmentIds
     * @return Integer
     */
    Integer updateQuarterSales(@Param("departmentIds") List<Long> departmentIds);

    /**
     * 更新目标达成率=季度销售额/目标金额
     *
     * @return Integer
     */
    Integer updateTargetReachRate();

    /**
     * 指定部门季度目标
     *
     * @param mcnPage
     * @param dto
     * @return
     */
    Page<DepartmentTargetPageVO> targetPage(McnPage<DepartmentTargetPageVO> mcnPage, @Param("dto") DepartmentTargetSearchDTO dto);
}
